#include <iostream>
#include <string>
#include <vector>
#include <time.h>
#include <fstream>

#include "ca_al.h"
#include "bm_cal.h"



int main()
{
    CCaOpers<char> a;
    //std::ifstream istream("D:\\testdir\\ca_al\\Debug\\words");
    //std::ofstream ostream("paternlib.dat", std::ios_base::binary|std::ios_base::trunc);
    std::ifstream istream_2("paternlib.dat", std::ios_base::binary);
    
    /*std::string temppattern;
    uint pattercounter = 1;
    CCaOpers<char>::dststate dst;
    while(!istream.eof() && pattercounter <= 1000)
    {
        istream >> temppattern;
        for(uint chcounter = 0; chcounter < temppattern.size(); ++chcounter)
        {
            if(chcounter == (temppattern.size() - 1))
            {
                dst.m_tag.push_back(pattercounter);
            }
            a.addAnEntry(temppattern[chcounter], dst);
            dst.m_tag.clear();
        }
        ++pattercounter;
        temppattern.clear();
    }
    a.fix();
    a.save(ostream);
    ostream.close();
    a.clear();*/
    a.load(istream_2);
    istream_2.close();
    
    std::string str = "dfsdfdsfifdfdfayeAarhussoksdsdsadwaasdwdawdadawadwdawr3rsadcsadsadwdadsdawdwasdwewdasdsadsadsadsadsadsadsadsadsadwadsadasxdsasdsad";
    clock_t start,finish;
    start = clock();
    int counter=0;
    for(counter=0; counter <300000; ++counter)
    {
        a.query_f(str.begin(), str.end());
    }
    finish=clock();
    double duration = (double)(finish - start) / CLOCKS_PER_SEC;
    printf( "%2.5f %u \n", duration , str.length() * counter);
    
    
    a.printResult();

    CBMOpers<char> b;
    std::vector<char> src; 
    std::vector<char> pat;
    CBMOpers<char>::stringtovect("dawdadawadwdawr3rsadcsadsadwdads", pat);
    CBMOpers<char>::stringtovect(str, src);
    start = clock();
    for(counter=0; counter < 300000000; ++counter)
    {
        b.query_f(src, pat, 1);
    }
    finish=clock();
    duration = (double)(finish - start) / CLOCKS_PER_SEC;
    printf( "%2.5f %u \n", duration , str.length() * counter);    
    
};